package handler

import (
	"ginweb/module/db"
	"ginweb/module/db/model"

	"github.com/gin-gonic/gin"
)

// Login 用户登录
func Login(c *gin.Context) {

	account := c.Param("account")
	password := c.Param("password")

	var user model.SysUser
	has, err := db.Ins.Where("account = ?", account).Get(&user)
	if err != nil {
		c.JSON(500, "param error")
	} else {
		if has {
			if user.Password == password {
				c.JSON(200, "token")
			} else {
				c.JSON(500, "account or password error")
			}
		} else {
			c.JSON(500, "account or password error")
		}
	}

	return
}
